﻿/*
 * 转换类型字典
 * 
 * By hkl
 * At 20110503
 * */

namespace AcctrueWMS.Foundation.Web
{
    using System;
    using System.Collections.Generic;

    public sealed class TypeConverter
    {
        private static TypeConverter converter;
        private static Dictionary<string, Type> dirType = new Dictionary<string, Type>();//字典

        private static object syncRoot = new Object();//为了解决多线程，而添加的一个附加变量，以避免死锁
        static TypeConverter()
        {
            dirType.Add("String", typeof(string));
            dirType.Add("Int", typeof(int));
            dirType.Add("Int32", typeof(int));
            dirType.Add("Decimal", typeof(decimal));
            dirType.Add("DateTime", typeof(DateTime));
            dirType.Add("Float", typeof(float));
            dirType.Add("Boolean", typeof(bool));
        }

        public static TypeConverter Converter
        {
            get
            {
                if (converter == null)
                {
                    lock (syncRoot)
                    {
                        if (converter == null)
                        {
                            converter = new TypeConverter();
                        }
                    }
                }
                return converter;
            }
        }
        public Dictionary<string, Type> DirType
        {
            get { return dirType; }
        }
    }
}
